
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML5/CSS3水平二级下拉菜单DEMO演示</title>
    <!-- 第二步：css样式代码 -->
    <style>
        .dropdownmenu ul, .dropdownmenu li {
            margin: 0;
            padding: 0;
        }
        .dropdownmenu ul {
            background: gray;
            list-style: none;
            width: 100%;
        }
        .dropdownmenu li {
            float: left;
            position: relative;
            width:auto;
        }
        .dropdownmenu a {
            background: #30A6E6;
            color: #FFFFFF;
            display: block;
            font: bold 12px/20px sans-serif;
            padding: 10px 25px;
            text-align: center;
            text-decoration: none;
            -webkit-transition: all .25s ease;
            -moz-transition: all .25s ease;
            -ms-transition: all .25s ease;
            -o-transition: all .25s ease;
            transition: all .25s ease;
        }
        .dropdownmenu li:hover a {
            background: #000000;
        }
        /* 默认隐藏使用opacity设置透明度为0
        visibility（可见度）设置为元素是不可见的 */
        #submenu {
            left: 0;
            opacity: 0;
            position: absolute;
            top: 35px;
            visibility: hidden;
            z-index: 1;
        }
        /* 鼠标移入li 让ul下的二级菜单显示
            opacity透明度设置为1，可见度设置为默认显示*/
        li:hover ul#submenu {
            opacity: 1;
            top: 40px;
            visibility: visible;
        }
        #submenu li {
            float: none;
            width: 100%;
        }
        #submenu a:hover {
            background: #DF4B05;
        }
        #submenu a {
            background-color:#000000;
        }
    </style>
</head>
<body>
    <!-- 第一步：导航代码布局 -->
    <nav class="dropdownmenu">
    <ul>
        <li><a href="#">首页</a></li>
        <li><a href="#">关于我们</a></li>
        <!-- 二级菜单 -->
        <li><a href="#">前端技术</a>
        <ul id="submenu">
            <li><a href="#">CSS3</a></li>
            <li><a href="#">HTML5</a></li>
            <li><a href="#">VUE3</a></li>
        </ul>
        </li>
        <li><a href="#">新闻</a></li>
        <li><a href="#">联系我们</a></li>
    </ul>
    </nav>
</body>
</html>